package day1;

import java.util.Scanner;

public class Demo2 {
    public static void main(String[] args) {
        //从键盘录入两个正整数，输出他俩的最大公约数和最小公倍数
        System.out.println("请输入两个正整数");
        Scanner sc = new Scanner(System.in);
        int n1 = sc.nextInt();
        int n2 = sc.nextInt();
        //如果两数相等
        if (n1 == n2) {
            System.out.println("最大公约数和最小公倍数都是：" + n1);
            return;
        }
        //两数不等，先取最大数
        int max = (n1 > n2) ? n1 : n2;
        int min = (n1 < n2) ? n1 : n2;

//        if(n1>n2){
//            max = n1;
//        }else{
//            max = n2;}

        //计算
        int temp = max % min;
        while (temp != 0) {
            max = min;
            min = temp;
            temp = max % min;
        }
        System.out.println("最大公约数为：" + min);
        System.out.println("最小公倍数为：" + n1*n2/min);

    }


}
